<!--
 * @Author: wjc
 * @Date: 2025-02-13 14:52:31
 * @LastEditors: wjc
 * @LastEditTime: 2025-10-28 14:31:41
 * @Description: 
-->
<template>
  <el-avatar v-if="url" :size="size" :src="getImage(url, { width: size })" />
  <el-avatar v-else :size="size">{{ name && name.substring(0, 1) }}</el-avatar>
</template>

<script setup lang="ts">
  import { getImage } from '#/utils/image'

  defineOptions({
    name: 'MAvatar',
  })

  withDefaults(
    defineProps<{
      name: string
      size?: number
      url: null | string
    }>(),
    {
      size: 96,
    }
  )
</script>
